import { ErrorCode } from "../../src/config/ErrorCode";
import { GameConfig } from "../../src/config/GameConfig";
import { ServerConfig } from "../../src/config/ServerConfig";
import { ResponseModel } from "../../src/model/ResponseModel";
import { AccountDao } from "../dao/AccountDao";
import { AccountEntity } from "../entity/AccountEntity";

const Time_Check_Inteval: number = 1000 * 60 * 60
const Time_Delete_Inteval: number = 1000 * 60 * 60 * 24

export class AccountModel {

    public static async login_async(account: string, sign: string){
        let respModel:ResponseModel = new ResponseModel()
        let accountResult: AccountEntity = await AccountDao.get_account_info(account)
        if (accountResult) {
            if (ServerConfig.nowServerConfig.status == ServerConfig.Status_Type.Weihu) {
                if (accountResult.status != GameConfig.Status_Type.Test) {
                    respModel.code = ErrorCode.Code.Fail;
                    respModel.msg = "服务器维护"
                }
            }
            if (sign == accountResult.token) {
                respModel.code = ErrorCode.Code.Suc;
                respModel.msg = ""
            } else {
                respModel.code = ErrorCode.Code.LoginError_token;
                respModel.msg = "token错误,请重新登录"
            }
        } else {
            respModel.code = ErrorCode.Code.LoginError_NoUser;
            respModel.msg = "账号不存在"
        }
        return respModel;
    }


}